home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / util / printps.zip / PSDRV.C < prev   
C/C++ Source or Header  |  1994-01-19  |  5KB  |  156 lines

  1. #define lineentete 815
  2. #define firstline  795
  3. #define __MSC /* For Borland C++ */
  4. #include <bios.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7.  
  8. /* PSDRV.C */
  9. void PrintProlog() ;
  10. void PrintEnd() ;
  11. void SelectCourier (int corps) ;
  12. void SelectTimes   (int corps) ;
  13. void SelectHelv    (int corps) ;
  14. void PrintTextAt(int x,int y,unsigned char * text) ;
  15.  
  16. /* PRINTPS.C */
  17. void SendText(char *pText) ;
  18.  
  19.  
  20. void PrintProlog()
  21. {
  22.   SendText("%!PS-Adobe-2.0 EPSF-1.2\n") ;
  23.   SendText("%%BoundingBox: 0 0 611 827\n") ;
  24.   SendText("%%Creator: Gilles Vollant\n") ;
  25.   SendText("%%Title: PrintPS file\n") ;
  26.   SendText("%%CreationDate: 11/8/91 12:00\n") ;
  27.   SendText("%%DocumentFonts:Courier Times-Roman\n") ;
  28.   SendText("%%DocumentNeeddedFonts: Courier Times-Roman\n") ;
  29.   SendText("%%IncludeFont: Courier Times-Roman\n") ;
  30.   SendText("%%EndComments\n") ;
  31.   SendText("/begdict 30 dict def\n") ;
  32.   SendText("begdict begin\n") ;
  33.   SendText("/reencsmalldict 12 dict def\n") ;
  34.   SendText("/ReEncodeSmall\n") ;
  35.   SendText("{ reencsmalldict begin\n") ;
  36.   SendText("/newcodesandnames exch def\n") ;
  37.   SendText("/newfontname exch def\n") ;
  38.   SendText("/basefontname exch def\n") ;
  39.   SendText("/basefontdict basefontname findfont def\n") ;
  40.   SendText("/newfont basefontdict maxlength dict def\n") ;
  41.   SendText("basefontdict\n") ;
  42.   SendText("{ exch dup /FID ne\n") ;
  43.   SendText("{ dup /Encoding eq\n") ;
  44.   SendText("{ exch dup length array copy newfont 3 1 roll put }\n") ;
  45.   SendText("{ exch newfont 3 1 roll put }\n") ;
  46.   SendText("ifelse }\n") ;
  47.   SendText("{pop pop }\n") ;
  48.   SendText("ifelse }\n") ;
  49.   SendText("forall\n") ;
  50.   SendText("newfont /FontName newfontname put\n") ;
  51.   SendText("newcodesandnames aload pop\n") ;
  52.   SendText("newcodesandnames length 2 idiv\n") ;
  53.   SendText("{ newfont /Encoding get 3 1 roll put}\n") ;
  54.   SendText("repeat newfontname newfont definefont pop\n") ;
  55.   SendText("end }\n") ;
  56.   SendText("def\n") ;
  57.   SendText("/spanvec [\n") ;
  58.   SendText("8#200 /Ccedilla 8#201 /udieresis 8#202 /eacute 8#203\n") ;
  59.   SendText("/acircumflex 8#204 /adieresis 8#205 /agrave 8#206 /aring 8#207\n") ;
  60.   SendText("/ccedilla 8#210 /ecircumflex 8#211 /edieresis 8#212 /egrave\n") ;
  61.   SendText("8#213 /idieresis 8#214 /icircumflex 8#215 /igrave 8#216\n") ;
  62.   SendText("/Adieresis 8#217 /Aring 8#220 /Eacute 8#221 /ae 8#222 /AE 8#223\n") ;
  63.   SendText("/ocircumflex 8#224 /odieresis 8#225 /ograve 8#226 /ucircumflex\n") ;
  64.   SendText("8#227 /ugrave 8#230 /ydieresis 8#231 /Odieresis 8#232\n") ;
  65.   SendText("/Udieresis 8#233 /oslash 8#234 /sterling 8#235 /Oslash 8#240\n") ;
  66.   SendText("/aacute 8#241 /iacute 8#242 /oacute 8#243 /uacute 8#244 /ntilde\n") ;
  67.   SendText("8#245 /Ntilde 8#246 /ordfeminine 8#247 /ordmasculine 8#250\n") ;
  68.   SendText("/questiondown 8#251 /endash 8#255 /exclamdown 8#256\n") ;
  69.   SendText("/guillemotleft 8#257 /guillemotright 8#341 /germandbls 8#345\n") ;
  70.   SendText("/space 8#346 /u 8#347 /space 8#350 /space 8#351 /space 8#365\n") ;
  71.   SendText("/section 8#366 /dotlessi 8#370 /ring 8#376 /endash\n") ;
  72.   SendText("] def\n") ;
  73.   SendText("end\n") ;
  74.  
  75.   SendText("save begdict begin\n") ;
  76.  
  77.   SendText("1 setlinewidth 0 setlinecap 0 setlinejoin [] 0 setdash\n") ;
  78.   SendText("0 setgray 10 setmiterlimit\n") ;
  79.  
  80.   SendText("/Helvetica  /IntlHelvetica spanvec ReEncodeSmall\n") ;
  81.   SendText("/Courier     /IntlCourier spanvec ReEncodeSmall\n") ;
  82.   SendText("/Times-Roman /IntlTimes-Roman spanvec ReEncodeSmall\n") ;
  83.   SendText("newpath\n") ;
  84.  
  85.   SendText("%%EndProlog\n\n") ;
  86. }
  87.  
  88. void PrintEnd()
  89. {
  90.   SendText("end restore currentfile closefile\n");
  91. }
  92.  
  93. void PrintPage()
  94. {
  95.   SendText("showpage\n") ;
  96. }
  97.  
  98. void SelectTimes (int corps)
  99. {
  100. char line[80] ;
  101.   sprintf(line,
  102.     "%d /IntlTimes-Roman findfont exch scalefont setfont\n",corps) ;
  103.   SendText(line) ;
  104. }
  105.  
  106. void SelectHelv (int corps)
  107. {
  108. char line[80] ;
  109.   sprintf(line,"%d /IntlHelvetica findfont exch scalefont setfont\n",corps) ;
  110.   SendText(line) ;
  111. }
  112.  
  113. void SelectCourier (int corps)
  114. {
  115. char line[80] ;
  116.   sprintf(line,"%d /IntlCourier findfont exch scalefont setfont\n",corps) ;
  117.   SendText(line) ;
  118. }
  119.  
  120. void ConvOctal (char * buf, unsigned char c,int lg)
  121. {
  122. char ch[20] ;
  123. int i ;
  124.  
  125.   sprintf(ch,"%o",c) ;
  126.   for (i = 0;(int)((i + strlen(ch))) < lg;i++,buf++) *buf = '0' ;
  127.   strcpy(buf,ch) ;
  128. }
  129.  
  130. void PrintTextAt(int x,int y,unsigned char * text)
  131. {
  132. char line[512] ;
  133. int i = 1 ;
  134.   sprintf(line,"%d %d moveto\n",x,y) ;
  135.   SendText (line) ;
  136.   line[0] = '(' ;
  137.   while ((*(text) != '\0') && (i+3) < 255)
  138.     {
  139.       if (*text == ')' || *text == '(' || *text == '\\')
  140.       line[i++] = '\\' ;
  141.       if (*text >= 32 && *text <= 128)
  142.       line[i++] = *text ;
  143.        else
  144.      {
  145.        line[i++] = '\\' ;
  146.        ConvOctal(&line[i],*text,3) ;
  147.        i += 3 ;
  148.      }
  149.       text ++ ;
  150.     }
  151.  
  152.   line[i] = '\0' ;
  153.   strcat(line,") show\n") ;
  154.   SendText(line) ;
  155. }
  156.